package com.tx.utils;

import com.tx.constant.ResultCode;
import com.tx.model.WsResult;

/**
 * @author dengguoxing
 * @date 2019/11/6 15:59
 * description
 **/
public class WsResultUtil {

    public static WsResult success() {
        WsResult result = WsResult.Builder.aResult()
                .withCode(ResultCode.OK.getCode())
                .withMessage(ResultCode.OK.getMsg())
                .build();

        return result;
    }

    public static WsResult success(String msg) {
        WsResult result = WsResult.Builder.aResult()
                .withCode(ResultCode.OK.getCode())
                .withMessage(msg)
                .build();

        return result;
    }

    public static WsResult error(String msg) {
        WsResult result = WsResult.Builder.aResult()
                .withCode(ResultCode.ERROR.getCode())
                .withMessage(msg)
                .build();

        return result;
    }

    public static WsResult error(String msg, int code) {
        WsResult result = WsResult.Builder.aResult()
                .withCode(code)
                .withMessage(msg)
                .build();

        return result;
    }

}
